From: Jeroen van der Heijden Date: Mon, 8 Oct 2018 09:16:15 +0000 (+0200) Subject: Added extra info on failure X-Git-Tag: archive/raspbian/2.0.44-1+rpi1~1^2~3^2~8^2~23 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=b7fce0b078175bff984b9ba3ee71f14df8944e1b;p=siridb-server.git Added extra info on failure --- diff --git a/itest/testing/server.py b/itest/testing/server.py index a641207c..81186887 100644 --- a/itest/testing/server.py +++ b/itest/testing/server.py @@ -11,12 +11,20 @@ from .constants import SIRIDBC from .constants import TEST_DIR from .constants import VALGRIND from .constants import MAX_OPEN_FILES +from .color import Color + MEM_PROC = \ 'memcheck-amd64-' if platform.architecture()[0] == '64bit' else \ 'memcheck-x86-li' +def get_file_content(fn): + with open(fn, 'r') as f: + data = f.read() + return data + + class Server: HOLD_TERM = False GEOMETRY = '140x60' @@ -128,13 +136,11 @@ class Server: SIRIDBC.format(BUILDTYPE=self.BUILDTYPE), self.cfgfile), shell=True) - else: - with open( - f'testdir/{self.test_title}-{self.name}-err.log', - 'a') as err: - with open( - f'testdir/{self.test_title}-{self.name}-out.log', - 'a') as out: + elif self.TERMINAL is None: + errfn = f'testdir/{self.test_title}-{self.name}-err.log' + outfn = f'testdir/{self.test_title}-{self.name}-out.log' + with open(errfn, 'a') as err: + with open(outfn, 'a') as out: self.proc = subprocess.Popen( '{}{} --config {}' .format(VALGRIND if self.MEM_CHECK else '', @@ -147,7 +153,22 @@ class Server: await asyncio.sleep(5) my_pid = self._get_pid_set() - prev - assert (len(my_pid) == 1) + if len(my_pid) != 1: + if self.TERMINAL is None: + if os.path.exists(outfn) and os.path.getsize(outfn): + reasoninfo = get_file_content(outfn) + elif os.path.exists(errfn): + reasoninfo = get_file_content(errfn) + else: + reasoninfo = 'unknown' + assert 0, ( + f'{Color.error("Failed to start SiriDB server")}\n' + f'{Color.info(reasoninfo)}\n') + else: + assert 0, ( + 'Failed to start SiriDB server. A possible reason could ' + 'be that another process is using the same port.') + self.pid = my_pid.pop() if sleep: await asyncio.sleep(sleep)